/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	深圳市国省检日常化监管系统         </p>
 * <p>创建者   :	heyong 
 * 
 * <p>描   述  :   MainTenanceProject.java for com.pengtu.gsj.entity.jsbz    </p>
 * 
 * <p>最后修改 : $: 2017年8月7日-上午11:59:38 v 1.0.0	 win7   $ </p>
 * 
*/
package com.pengtu.gsj.controller.jsbz;


import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pengtu.gsj.controller.base.DefaultBaseController;
import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.entity.jsbz.MainTenanceProject;
import com.pengtu.gsj.interceptor.Token;
import com.pengtu.gsj.service.jsbz.MainTenanceProjectService;

/**
 * 
 * 
 * MainTenanceProjectController
 * 养护工程项目
 * 2017年8月7日 下午2:53:37
 * 
 * @version 1.0.0
 *
 */
@Controller
@RequestMapping("mainTenanceProject")
public class MainTenanceProjectController extends DefaultBaseController {
	
	@Autowired
	private MainTenanceProjectService mainTenanceProjectService;
	
	/**
	 * 加载
	 * @param id
	 * @return
	 */
	@ModelAttribute
	public MainTenanceProject load(String id){
		MainTenanceProject mainTenanceProject;
		if(StringUtils.isNotEmpty(id)){
			mainTenanceProject = mainTenanceProjectService.getMainTenanceProjectById(id);
		}else{
			mainTenanceProject = new MainTenanceProject();
		}
		return mainTenanceProject;
	}
	
	
	/**
	 * 
	 * showLisfInfo:
	 * 适用:跳转到显示大中修数据记录列表
	 * @return 
	 * @exception 
	 * @since  1.0.0
	 */
	@RequestMapping("listInfo")
	@Token(save = true)
	public String showLisfInfo() {
		return "jsbz/mainTenanceProject_list";
	}
	
	@RequestMapping(value="list", produces = "application/json; charset=utf-8")
	@ResponseBody
	public Page<MainTenanceProject> getRoadMaterialList(Page<MainTenanceProject> page, HttpServletRequest request){
		QueryFilter queryFilter = QueryFilter.buildFromHttpRequest(request);
		if (!page.isOrderBySetted()) {
			page.setOrderBy("year");
			page.setOrder(Page.ASC);
		}
		page = mainTenanceProjectService.findMainTenanceProject(page,queryFilter);
		return page;
	}
	
	/**
	 * 保存
	 * @param roadMaterial
	 * @return
	 */
	@RequestMapping(value = "save", method=RequestMethod.POST)
	@ResponseBody
	@Token(remove = true)
	public boolean saveMainTenanceProject(@ModelAttribute MainTenanceProject mainTenanceProject){
		mainTenanceProjectService.saveMainTenanceProject(mainTenanceProject);
		return true;
	}
	
	
	/**
	 * 加载数据
	 * @param infoManagement
	 * @return
	 */
	@RequestMapping(value="show")
	@ResponseBody                                                     
	public MainTenanceProject showMainTenanceProject (@ModelAttribute MainTenanceProject mainTenanceProject){
		return mainTenanceProject;
	}
	
	/**
	 * 删除
	 * @param infoManagement
	 * @return
	 */
	@RequestMapping(value="delete")
	@ResponseBody
	public boolean delateInfoManagement(@ModelAttribute MainTenanceProject mainTenanceProject){
		mainTenanceProjectService.delateMainTenanceProject(mainTenanceProject);
		return true;
	}
	
	
}
